package com.hpin.fansea.home;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hpin.fansea.R;
import com.hpin.fansea.base.BaseActivity;
import com.hpin.fansea.utils.CommonUtils;

/**
 * 物业费缴费 二级页面
 * Created by Aaron on 15/9/14.
 */
public class PaymentDetailActivity extends BaseActivity {

    private ImageView iv_weixin;
    private ImageView iv_zhifubao;
    private ImageView iv_one;
    private ImageView iv_three;
    private ImageView iv_six;
    private ImageView iv_year;
    private EditText et_pay;
    private TextView tv_this_year;
    private TextView tv_history;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        setContentView(R.layout.activity_payment_detail);

        String contact = getIntent().getStringExtra("contact");
        String phone = getIntent().getStringExtra("phone");
        String unitName = getIntent().getStringExtra("unitName");

        initWidget();

        getPayInfo();
    }

    private void initWidget() {

        ImageView iv_left = (ImageView) findViewById(R.id.iv_left);
        TextView tv_title = (TextView) findViewById(R.id.tv_title);

        tv_title.setText(getResources().getString(R.string.pay));

        iv_left.setOnClickListener(this);

        tv_this_year = (TextView) findViewById(R.id.tv_pay_this_year);
        tv_history = (TextView) findViewById(R.id.tv_history);

        et_pay = (EditText) findViewById(R.id.et_pay);

        RelativeLayout rl_one = (RelativeLayout) findViewById(R.id.rl_one);
        RelativeLayout rl_three = (RelativeLayout) findViewById(R.id.rl_three);
        RelativeLayout rl_six = (RelativeLayout) findViewById(R.id.rl_six);
        RelativeLayout rl_total = (RelativeLayout) findViewById(R.id.rl_total);

        iv_one = (ImageView) findViewById(R.id.iv_one);
        iv_three = (ImageView) findViewById(R.id.iv_three);
        iv_six = (ImageView) findViewById(R.id.iv_six);
        iv_year = (ImageView) findViewById(R.id.iv_year);

        RelativeLayout rl_weix = (RelativeLayout) findViewById(R.id.rl_weix);
        RelativeLayout rl_zhifb = (RelativeLayout) findViewById(R.id.rl_zhifb);

        iv_weixin = (ImageView) findViewById(R.id.iv_weixin);
        iv_zhifubao = (ImageView) findViewById(R.id.iv_zhifubao);

        Button btn_commit = (Button) findViewById(R.id.btn_commit);


        rl_one.setOnClickListener(this);
        rl_three.setOnClickListener(this);
        rl_six.setOnClickListener(this);
        rl_total.setOnClickListener(this);

        rl_weix.setOnClickListener(this);
        rl_zhifb.setOnClickListener(this);

        btn_commit.setOnClickListener(this);
    }

    /**
     * 获取缴费信息
     */
    private void getPayInfo() {

    }


    @Override
    public void widgetClick(View v) {
        switch (v.getId()) {

            case R.id.iv_left:

                finish();

                break;

            case R.id.rl_one:

                iv_one.setSelected(true);
                iv_three.setSelected(false);
                iv_six.setSelected(false);
                iv_year.setSelected(false);

                break;

            case R.id.rl_three:

                iv_one.setSelected(false);
                iv_three.setSelected(true);
                iv_six.setSelected(false);
                iv_year.setSelected(false);

                break;

            case R.id.rl_six:

                iv_one.setSelected(false);
                iv_three.setSelected(false);
                iv_six.setSelected(true);
                iv_year.setSelected(false);

                break;

            case R.id.rl_total:

                iv_one.setSelected(false);
                iv_three.setSelected(false);
                iv_six.setSelected(false);
                iv_year.setSelected(true);

                break;

            case R.id.rl_weix:

                iv_weixin.setSelected(true);
                iv_zhifubao.setSelected(false);

                break;

            case R.id.rl_zhifb:

                iv_weixin.setSelected(false);
                iv_zhifubao.setSelected(true);

                break;

            case R.id.btn_commit:

                commit();

                break;


        }

    }

    /**
     * 提交
     */
    private void commit() {

        if (CommonUtils.isNull(et_pay.getText().toString().trim())) {
            showToast("请输入缴费金额");
            return;
        }

        if (!iv_one.isSelected() && !iv_three.isSelected() && !iv_six.isSelected() && !iv_year.isSelected()) {
            showToast("请选择缴费时长");
            return;
        }

        if (!iv_weixin.isSelected() && !iv_zhifubao.isSelected()) {
            showToast("请选择支付方式");
            return;
        }

    }
}
